package com.briup.corejava.day15;

import com.briup.corejava.day15.exception.EditUserInfoException;
import com.briup.corejava.day15.exception.LoginException;

import java.util.Arrays;

/**
 * 异常测试
 */
public class Test2 {
    public static void run(int b ){
        int a = 10;
        assert b!=0 : "除数不能为0";
        System.out.println(a / b);

        throw new EditUserInfoException();
    }
    public static void test(String name) throws LoginException {
        if(!"tom".equals(name)){
            throw new LoginException("登陆失败，用户名不正确");
        }
    }
    public static void main(String[] args) {
        System.out.println(Arrays.toString(args));
        // 直接处理异常
        try {
            run(10);
            test("jerry");
        }catch (LoginException e){
            System.err.println("登陆失败");
        }catch (EditUserInfoException e){
            System.err.println("修改失败");
        }finally {
            System.out.println("关闭资源");
        }
    }
}
